package xinxin.com.MementoPattern.Role;

import xinxin.com.MementoPattern.Memento.RoleStateMemento;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/3/28 13:17
 */
public class GameRole {
    /**
     * 生命力
     */
    private int vit;
    /**
     * 攻击力
     */
    private int atk;
    /**
     * 防御力
     */
    private int def;

    public GameRole() {
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    /**
     * 获得初始状态
     */
    public void GetInitState() {
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    /**
     * 战斗
     */
    public void Fight() {
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }

    @Override
    public String toString() {
        return "Role{" +
                "vit=" + vit +
                ", atk=" + atk +
                ", def=" + def +
                '}';
    }

    public void stateDisplay() {
        System.out.println(toString());
    }

    public RoleStateMemento saveState() {
        return new RoleStateMemento(vit, atk, def);
    }

    public void recoveryState(RoleStateMemento memento) {
        this.vit = memento.getVit();
        this.atk = memento.getAtk();
        this.def = memento.getDef();
    }
}
